-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

=============================================================================
FreeBSD-SA-21:08.vm                                         Security Advisory
                                                          The FreeBSD Project

Topic:          Memory disclosure by stale virtual memory mapping

Category:       core
Module:         vm
Announced:      2021-04-06
Credits:        Ryan Libby, Dell Inc.
Affects:        All supported versions of FreeBSD.
Corrected:      2021-04-06 18:50:46 UTC (stable/13, 13.0-STABLE)
                2021-04-06 19:18:49 UTC (releng/13.0, 13.0-RC5-p1)
                2021-04-06 19:20:46 UTC (stable/12, 12.2-STABLE)
                2021-04-06 19:21:30 UTC (releng/12.2, 12.2-RELEASE-p6)
                2021-04-06 19:22:31 UTC (stable/11, 11.4-STABLE)
                2021-04-06 19:22:56 UTC (releng/11.4, 11.4-RELEASE-p9)
CVE Name:       CVE-2021-29626

For general information regarding FreeBSD Security Advisories,
including descriptions of the fields above, security branches, and the
following sections, please visit <URL:https://security.FreeBSD.org/>.

I.   Background

Memory mappings shared between processes are a feature of the FreeBSD
virtual memory system.  They may be established by unprivileged
processes with the mmap(2), fork(2), and other system calls.

II.  Problem Description

A particular case of memory sharing is mishandled in the virtual memory
system.  It is possible and legal to establish a relationship where
multiple descendant processes share a mapping which shadows memory of an
ancestor process.  In this scenario, when one process modifies memory
through such a mapping, the copy-on-write logic fails to invalidate
other mappings of the source page.  These stale mappings may remain even
after the mapped pages have been reused for another purpose.

III. Impact

An unprivileged local user process can maintain a mapping of a page
after it is freed, allowing that process to read private data belonging
to other processes or the kernel.

IV.  Workaround

No workaround is available.

V.   Solution

Upgrade your vulnerable system to a supported FreeBSD stable or
release / security branch (releng) dated after the correction date
and reboot.

Perform one of the following:

1) To update your vulnerable system via a binary patch:

Systems running a RELEASE version of FreeBSD on the amd64, i386, or
(on FreeBSD 13 and later) arm64 platforms can be updated via the
freebsd-update(8) utility:

# freebsd-update fetch
# freebsd-update install
# shutdown -r +10min "Rebooting for a security update"

2) To update your vulnerable system via a source code patch:

The following patches have been verified to apply to the applicable
FreeBSD release branches.

a) Download the relevant patch from the location below, and verify the
detached PGP signature using your PGP utility.

[FreeBSD 13.0]
# fetch https://security.FreeBSD.org/patches/SA-21:08/vm_fault.13.patch
# fetch https://security.FreeBSD.org/patches/SA-21:08/vm_fault.13.patch.asc
# gpg --verify vm_fault.13.patch.asc

[FreeBSD 12.2]
# fetch https://security.FreeBSD.org/patches/SA-21:08/vm_fault.12.patch
# fetch https://security.FreeBSD.org/patches/SA-21:08/vm_fault.12.patch.asc
# gpg --verify vm_fault.12.patch.asc

[FreeBSD 11.4]
# fetch https://security.FreeBSD.org/patches/SA-21:08/vm_fault.11.patch
# fetch https://security.FreeBSD.org/patches/SA-21:08/vm_fault.11.patch.asc
# gpg --verify vm_fault.11.patch.asc

b) Apply the patch.  Execute the following commands as root:

# cd /usr/src
# patch < /path/to/patch

c) Recompile your kernel as described in
<URL:https://www.FreeBSD.org/handbook/kernelconfig.html> and reboot the
system.

VI.  Correction details

The following list contains the correction revision numbers for each
affected branch.

Branch/path                      Hash                            Revision
- -------------------------------------------------------------------------
stable/13/                       2e08308d62f3           stable/13-n245117
releng/13.0/                     724bc23da1a9         releng/13.0-n244728
stable/12/                                                        r369551
releng/12.2/                                                      r369556
stable/11/                                                        r369559
releng/11.4/                                                      r369561
- -------------------------------------------------------------------------

For FreeBSD 13 and later:

Run the following command to see which files were modified by a
particular commit:

# git show --stat <commit hash>

Or visit the following URL, replacing HHHHHH with the hash:

<URL:https://cgit.freebsd.org/src/commit/?id=HHHHHH>

To determine the commit count in a working tree (for comparison against
nNNNNNN in the table above), run:

# git rev-list --count --first-parent HEAD

For FreeBSD 12 and earlier:

Run the following command to see which files were modified by a particular
revision, replacing NNNNNN with the revision number:

# svn diff -cNNNNNN --summarize svn://svn.freebsd.org/base

Or visit the following URL, replacing NNNNNN with the revision number:

<URL:https://svnweb.freebsd.org/base?view=revision&revision=NNNNNN>

VII. References

<URL:https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-29626>

The latest revision of this advisory is available at
<URL:https://security.FreeBSD.org/advisories/FreeBSD-SA-21:08.vm.asc>
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEE/A6HiuWv54gCjWNV05eS9J6n5cIFAmBsveMACgkQ05eS9J6n
5cJ0Xw/+JFP6UKPMxcYwmAmIoDS5YAsUzuDVQNooZzOQiltyVqPrHD3Dh/32+Tm3
W6yeITNcnUbVhFBPli3x0pHldCCcj1JQNtzUYcS/DKNvD2LxjB4bhiiE0YHImaP9
JWOMoc5rNYpOl4iKK5DZkQAxZsHu1zFSVt+0O/aL70bDCYupsslWBbRRkxgkeShW
wGFhSMhlJ1QnnygzsICbyK5GP4XYqfAWZ5dviznNcZLrOifCLG6HNxixfOG/vf33
yZzwA7RSNpOyULC1AYmUqiEZWgABL63hOIiraD0sASteBhMY/DCjq/QLZKsaONsp
FYemSTnW1hs1MVfTm4ecwgZJEJf8bV7cQXrxA3bLJmRoN9CcTGHDQCjFKHvMVXSe
qU/n+CICO6Ly8nTmL0xYjpJLEQaQfC/98hXk2otpgIia8r5Gn1MOwooTdN+KWlfA
LHzuP0Wf5NIjo1QkbbBRUSfCjV+dbGzRxgCYTGj1dN+XbR0uxeVtWeKXU3WaDIYI
6sT3L41yUBvEce7h/449RunNjRb5nuWczh3YTIzqDA3dEStLPKxlzL790M8TId6e
XE+YclkxSTNMuxvCEw/vDJB4bZ2eOQ6noSzfrUqxjGnbtcuYP/RJGc3XrVZpiXbY
u+OuE4Owve9e/sNCRqZeEQ2CHnntCdji0sk/CAlbkHcdHYPbunI=
=rC4V
-----END PGP SIGNATURE-----
